gen :: Integer -> Integer -> Integer -> Integer
gen x y 0 = y
gen x y z = gen y f (z-1) 
    where f = y^2 + x
    
main = do
    l <- getLine
    let [x, y, z] = map read $ words l
    print $ gen x y (z-2)